import router from "@/router"

export function setDynamicRoute(menuList: any) {
  // 根据菜单生成路由
  menuList.forEach((oneMenu: any) => {
    oneMenu.children.forEach((twoMenu: any) => {
      router.addRoute("main", {
        path: twoMenu.path,
        name: twoMenu.path.replace("/", ""),
        component: () =>
          import(
            `@/views/main/${oneMenu.file}/${twoMenu.path.replace(
              "/",
              ""
            )}/${twoMenu.path.replace("/", "")}.vue`
          )
      })
    })
  })
}
